<template>
    <div>
        <el-form :inline="true" :model="arr" class="demo-form-inline">
            <el-form-item label="操作人">
                <el-input v-model="arr.Operatorname" placeholder="操作人"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" @click="Show">搜索</el-button>
            </el-form-item>
        </el-form>
        <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
            <!-- <el-table-column type="selection" width="55"> </el-table-column> -->

            <el-table-column prop="content" label="内容" width="150">
                <template slot-scope="scope">{{ scope.row.content.substr(0,9) }}</template>
            </el-table-column>
            <el-table-column prop="classify" label="分类" width="120"> </el-table-column>
            <el-table-column prop="module" label="模块" width="170"> </el-table-column>
            <el-table-column prop="whether" label="是否异常" width="110">
                <template slot-scope="aaa">
                    <el-tag type="success" v-if="aaa.row.whether==true">是</el-tag>
                    <el-tag type="danger" v-if="aaa.row.whether==false">否</el-tag>
                </template>
            </el-table-column>
            <el-table-column prop="use" label="应用名称" width="150"> </el-table-column>
            <el-table-column prop="operatorname" label="操作人" width="150"> </el-table-column>
            <el-table-column label="创建时间" width="120">
                <template slot-scope="scope">{{ scope.row.createtimes.substr(0,10) }}</template>
            </el-table-column>
        </el-table>
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="arr.Pageindex"
            :page-sizes="[40, 80, 100]"
            :page-size="arr.Pagesize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
        >
        </el-pagination>
    </div>
</template>

<script>
import { DepartmentgetData } from '@/api/journal.js/';
export default {
    data() {
        return {
            total: 0,
            tableData: [],
            multipleSelection: [],
            //定义对象包含所需要的条件
            arr:{
                operatorname:'',
                Pageindex:1,
                Pagesize:40,
                Classify:'登录日志',
                Sortedby:'asce',
            },
        };
    },
    //构造函数
    created() {
        this.Show();
    },
    methods: {
        toggleSelection(rows) {
            if (rows) {
                rows.forEach((row) => {
                    this.$refs.multipleTable.toggleRowSelection(row);
                });
            } else {
                this.$refs.multipleTable.clearSelection();
            }
        },
        //显示列表
        Show() {
            //调用定义的对象
            DepartmentgetData(this.arr).then((res) => {
                console.log(res)
                this.tableData = res.plist;
                this.total = res.recordCount;
            });
        },
        //条数
        handleSizeChange(val) {
            //console.log(`每页 ${val} 条`);
            this.arr.Pagesize=val;
            this.Show()
        },
        //从第几页开始
        handleCurrentChange(val) {
            //console.log(`当前页: ${val}`);
            this.arr.Pageindex=val;
            this.Show()
        },
        handleSelectionChange(val) {
            this.multipleSelection = val;
        }
    }
};
</script>